﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "GcmpGuiQt.h"
#include "IUiCommonDialogFactory.h"

namespace gcmp
{
    class GCMP_GUI_QT_EXPORT UiCommonDialogFactory : public gcmp::IUiCommonDialogFactory
    {

        CANNOT_COPY_OR_ASSIGN(UiCommonDialogFactory);
    public:
        UiCommonDialogFactory();
        ~UiCommonDialogFactory();

    public:

        // IUIFactory_Deprecated 接口
        virtual UiCommonDialog::ButtonType ShowMessage(const std::wstring& windowTitle, const std::wstring& message, int buttonTypes, bool moveToBootomRight) override;
        virtual UiCommonDialog::ButtonType ShowMiniMessageBox(const std::wstring& windowTitle, const std::wstring& message, int buttonTypes, int positionType = (int)UiCommonDialog::PositionType::BottomRight,int width = 350,int height = 150) override;
        virtual int ShowMessageForCloseDocument(const std::wstring& docName, bool saveButtonStatus) override;
        virtual UiCommonDialog::ButtonType ShowInputBox(const std::wstring& windowTitle, const std::wstring& message, const std::wstring& defaultText, std::wstring& inputText) override;
        virtual std::wstring ShowOpenFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, bool bDirOnlyFlag = false) override;
        //virtual std::vector<std::wstring> ShowOpenFilesDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter) override;
        virtual std::wstring ShowOpenFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter,int& filterIndex, bool directoryOnlyFlag = false) override;
        virtual std::wstring ShowSaveFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, const std::wstring& title = L"") override;
        // 打开颜色对话框
        virtual UiCommonDialog::ButtonType ShowColorSelectionDialog(const Color& init, Color& seleted) override;

    private:
        /// \brief MessageBox上自定义按钮的配置
        struct ButtonSetting
        {
            std::wstring Name;/// 按钮文本
            bool IsEnable;/// 是否可点击
        };

        int ShowMessage(const std::wstring& windowTitle, const std::wstring& message, const std::vector<ButtonSetting>& buttons, int defbutton = 0);

        std::wstring ShowOpenFileDialog(const std::wstring & caption, const std::wstring & initialPath, const std::wstring & filter, int& filterIndex,bool directoryOnlyFlag, bool hasSameSuffixFlag = false);

    };
}
